class Solution {
public:
    bool isPalindrome(ListNode* head) 
    {
        int i=0;
        ListNode*p=head;
        vector <int>a;
        while(p)
        {
            a.push_back(p->val);
            p=p->next;
        }
        vector <int> b=a;
        reverse(a.begin(),a.end());  
        return a==b;
    }
};